package com.smalljj.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import com.smalljj.domain.Person;
import com.smalljj.repository.PersonRepository;
import com.smalljj.service.PersonService;

public class PersonServiceImpl  implements PersonService{
	    
	    @Autowired
	    private PersonRepository personRepository;//注入UserRepository

	    @Override
	    @Transactional
	    public void saveUser(Person user) {
	    	personRepository.save(user);
	        
	    }

	    @Override
	    @Transactional(readOnly=true)
	    public Person findUserById(Long id) {
	        return personRepository.findOne(id);
	    }

	    
	    @Override
	    @Transactional
	    public void updateUser(Person user) {
	    	personRepository.save(user);
	    }

	    @Override
	    @Transactional
	    public void deleteUserById(Long id) {
	    	personRepository.delete(id);
	    }
}
